incremental error algorithm